//
//  QTCircleCell.m
//  QTLifeCircle
//
//  Created by 徐腾 on 2017/1/15.
//  Copyright © 2017年 徐腾. All rights reserved.
//

#import "QTCircleCell.h"
#import "HMAdditions.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>

@interface QTCircleCell ()

@property (nonatomic,weak) UIImageView *imageView;

/** nameLabel */
@property (weak, nonatomic) UILabel *nameLabel;

@end


@implementation QTCircleCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    //创建图片
    //1 >> imageView
    UIImageView *iconView = [[UIImageView alloc] init];
    
    self.imageView = iconView;
    
    //设置圆角头像
    iconView.layer.masksToBounds = YES;
    iconView.layer.cornerRadius = 30;
    
    [self.contentView addSubview:iconView];
    
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.centerY.equalTo(self.contentView);
        make.width.height.mas_equalTo(60);
    }];
    
    //2 >> label
    UILabel *nameLabel = [[UILabel alloc] init];
    
    self.nameLabel = nameLabel;
    //nameLabel.text = @"asdasd";
    //文字居中
    nameLabel.textAlignment = NSTextAlignmentCenter;
    
    [self.contentView addSubview:nameLabel];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.mas_equalTo(iconView.mas_bottom).offset(10);
    }];
    
    
}


- (void)setModel:(QTCircleModel *)model {
    _model = model;
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:[UIImage imageNamed:@"home_error"]];
    
    self.nameLabel.text = model.title;
    
}


@end
